#ifndef __NJGIS_NJHTTP_H__
#define __NJGIS_NJHTTP_H__

#include <string>

#include "curl/curl.h"
#include "json/json.h"
#include "NxFile.h"
#include "NxFormParam.h"

namespace NJGIS
{
	namespace SERVICE
	{
		class NjHttpHelper
		{
		public:
			//! init
			static int init();

			/* TEST */
			//! Request -GET
			static int request_get_sync(const char* url, std::string &responsebody);

			//! Request -POST
			static int request_post_withform_sync( const char* url, INjFormParam* &list_form, INjLocalFiles* &list_files, std::string &responsebody );

			//! Request -PUT
			static int request_put_sync(const char* url, std::string &responsebody);

			/* JSON */
			//! Request -GET
			static int request_get_json_sync(const char* url, Json::Value &value);

			//! Request -POST
			static int request_post_withform_json_sync(const char* url, INjFormParam* &list_form, INjLocalFiles* &list_files, Json::Value &value);

			//! Request -PUT
			static int request_put_json_sync(const char* url, Json::Value &value);

			/* Other */
			//! Download
			static int download(const char* url, const char* path);

		private:
			//! reply
			static size_t req_reply(void *ptr, size_t size, size_t nmemb, void *stream);

			//! file reply
			static size_t req_reply_file(void *ptr, size_t size, size_t nmemb, FILE *stream);
		};
	}
}

#endif